package cn.ddm.hrm.controller;

import cn.ddm.hrm.services.IImgVerifyCodeService;
import cn.ddm.hrm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/imgVerifyCode")
public class ImgVerifyCodeController {

    @Autowired
    private IImgVerifyCodeService iImgVerifyCodeService;

    /**
     * 生成图片验证码
     * @param imageCodeKey
     * @return
     */
    @GetMapping("/{imageCodeKey}")
    public AjaxResult getCodeByKey(@PathVariable("imageCodeKey") String imageCodeKey) {
        return iImgVerifyCodeService.getCodeByKey(imageCodeKey);
    }

    /**
     * 校验图片验证码
     * @param params
     * @return
     */
    @PostMapping("/imageVerifyCode/verify")
    public AjaxResult verifyImgCode(@RequestBody Map<String,String> params){
        return iImgVerifyCodeService.verifyImgCode(params);
    }
}
